package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.pojo.Personnel;
import com.itheima.service.PersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/personnel")
public class PersonnelController {
    @Reference
    private PersonnelService personnelService;

    @RequestMapping("/findAll")
    public Result findAll(){
        try{
            List<Personnel> personnels = personnelService.findAll();
            return new Result(true,"查询企业人员成功",personnels);
        }catch (Exception e){
            return new Result(false,"查询企业人员失败");
        }
    }

    @RequestMapping("/register")
    public Result register(@RequestBody Personnel personnel){
        Result result = personnelService.add(personnel);
        return result;
    }
}
